/*
 * File Name:               ProfilerTimer.cs
 * 
 * Description:             用来分析某些过程消耗的时间
 * Author:                  lisiyu <576603306@qq.com>
 * Create Date:             2017/02/04
 */

using System;
using UnityEngine;

public static class ProfilerTimer
{
    private static float mLastTime;
    private static long mLastMem;
    public static void begin()
    {
        mLastTime = Time.realtimeSinceStartup;
        mLastMem = GC.GetTotalMemory(true);
    }

    public static void end(string tag = "method")
    {
        var nowTime = Time.realtimeSinceStartup;
        var nowMem = GC.GetTotalMemory(true); ;
        Debug.LogFormat("{0} used time is {1} alloc mem is {2} mb", tag, nowTime - mLastTime, (nowMem - mLastMem) >> 20);
        mLastTime = nowTime;
        mLastMem = nowMem;
    }
}
